package com.itheima.demo04;

import java.util.ArrayList;

public class Demo01 {

    public static void main(String[] args) {

        ArrayList<String> arrayList = new ArrayList<>();

        arrayList.add("张三");
        arrayList.add("张三丰");
        arrayList.add("张建国");
        arrayList.add("赵四");
        arrayList.add("流川枫");

        ArrayList<String> arrayList1 = new ArrayList<>();

        for(String a : arrayList){
            if(a.startsWith("张")){
                arrayList1.add(a);
            }
        }

        ArrayList<String> arrayList2 = new ArrayList<>();

        for(String b : arrayList1){

            if(b.length()==3){
                arrayList2.add(b);
            }
        }

        arrayList2.forEach(s -> System.out.println(s));

        System.out.println("-----------------------------------");

        arrayList.stream().filter(s -> s.startsWith("张")).forEach(s -> System.out.println(s));
    }
}
